version 16
/*****************************************************************************************************
STATA do-file that generates datafile and Figure B1 using the Norwegian Local Election Studies 1999-2015.
The dataset is used in the paper:

Public Sector Employment and Voter Turnout*
Benny Geys and Rune J. Sørensen

to be published in the American Politial Science Review 
*****************************************************************************************************/
* Data from the Norwegian Election Studies to Appendix Table B1 (Information sources)
clear all
cd "C:\Users\FAG89001\Dropbox\SASDATA\Lokalvalgsundersøkelsene 01.03 2018\Data\"
use Survey2015.dta
gen year=2015
gen knr=Kommnr*1

/* Survey Question: "Hvor viktig vil du si at følgende kilder er for deg personlig når det gjelder å få informasjon om politiske spørsmål i din
kommune? Angi din mening på en skala der 1 betyr “Ikke viktig”, og 5 betyr “svært viktig”. Sett ett kryss for hver kilde." */

gen 	NationalNewspapers	=	T32a
replace NationalNewspapers	=. 	if T32a>=6
gen 	LocalNewspapers		=	T32b
replace LocalNewspapers		=. 	if T32b>=6
gen 	TV					=	T32c
replace TV					=. 	if T32c>=6
gen 	Radio				=	T32d
replace Radio				=. 	if T32d>=6
gen 	DirectContact		=	T32e
replace DirectContact		=. 	if T32e>=6
gen 	DiscussionOthers	=	T32f
replace DiscussionOthers	=. 	if T32f>=6
gen 	SocialMedia			=	T32g
replace SocialMedia			=. 	if T32g>=6

tabstat NationalNewspapers LocalNewspapers TV Radio DirectContact DiscussionOthers SocialMedia, stats(mean N)

gen Sector		=	T57
replace Sector	=	T60 if Sector==.
tab Sector, nolab

gen 	Sector4	=	1 if Sector==1 | Sector==2  /* Private sector */
replace Sector4	=	2 if Sector==3 | Sector==4  /* Local government */
replace Sector4	=	3 if Sector==5				 /* Central government */
replace Sector4	=	4 if Sector>=6 | Sector==.  /* Other */

keep 	year knr NationalNewspapers LocalNewspapers TV Radio DirectContact DiscussionOthers SocialMedia Sector Sector4 
save N2015.dta, replace


*****************************************************   2011 ***********************************************************************************************
clear all
use Survey2011.dta
gen year=2011
replace knr=knr*1
gen 	NationalNewspapers_pap	=	P8a			/* Riksdekkende papiraviser */
replace NationalNewspapers_pap	=. 	if P8a>=6
gen 	NationalNewspapers_net	=	P8b			/* Riksdekkende nettaviser */
replace NationalNewspapers_net	=. 	if P8b>=6
gen		NationalNewspapers			=	max(NationalNewspapers_pap, NationalNewspapers_net)

gen 	LocalNewspapers_pap		=	P8c			/* Lokale paperaviser */
replace LocalNewspapers_pap		=. 	if P8c>=6
gen 	LocalNewspapers_net		=	P8d			/* Lokale nettaviser */
replace LocalNewspapers_net		=. 	if P8d>=6
gen		LocalNewspapers			=	max(LocalNewspapers_pap, LocalNewspapers_net)

gen 	TV					=	P8e
replace TV					=. 	if P8e>=6
gen 	Radio				=	P8f
replace Radio				=. 	if P8f>=6
gen 	DirectContact		=	P8j
replace DirectContact		=. 	if P8j>=6
gen 	DiscussionOthers	=	P8k
replace DiscussionOthers	=. 	if P8k>=6
gen 	SocialMedia			=	P8m
replace SocialMedia			=. 	if P8m>=6

gen 	Sector	= 	T54
replace Sector	=	T58 if Sector==.
tab Sector
					
gen 	Sector4	=	1 if Sector==1 | Sector==2 | Sector==3  /* Private sector */
replace Sector4	=	2 if Sector==4 | Sector==5  /* Local government */
replace Sector4	=	3 if Sector==6				 /* Central government */
replace Sector4	=	4 if Sector>=7 | Sector==.  /* Other */

keep year knr NationalNewspapers LocalNewspapers TV Radio DirectContact DiscussionOthers SocialMedia Sector Sector4
save N2011.dta, replace

*****************************************************   2007 ***********************************************************************************************
clear all
use Survey2007.dta
gen year=2007
gen knr=KOMMUNE*1

gen 	NationalNewspapers	=	Po15_A
replace NationalNewspapers	=. 	if Po15_A>=6
gen 	LocalNewspapers		=	Po15_B
replace LocalNewspapers		=. 	if Po15_B>=6
gen 	TV					=	Po15_C
replace TV					=. 	if Po15_C>=6
gen 	Radio				=	Po15_D
replace Radio				=. 	if Po15_D>=6
gen 	DirectContact		=	Po15_I
replace DirectContact		=. 	if Po15_I>=6
gen 	DiscussionOthers	=	Po15_J
replace DiscussionOthers	=. 	if Po15_J>=6

gen Sector=SPM55
replace Sector=SPM60 if Sector==.
tab Sector
gen 	Sector4	=	1 if Sector==1 | Sector==2 | Sector==3  /* Private sector */
replace Sector4	=	2 if Sector==4 | Sector==5  /* Local government */
replace Sector4	=	3 if Sector==6				 /* Central government */
replace Sector4	=	4 if Sector>=7 | Sector==.  /* Other */

keep year knr NationalNewspapers LocalNewspapers TV Radio DirectContact DiscussionOthers Sector Sector4 
save N2007.dta, replace

*********************************************************************  2003 **********************************************************************
clear all
use Survey2003.dta
gen year=2003
drop knr
gen knr=s_komm*1
gen 	NationalNewspapers	=	po18_a
replace NationalNewspapers	=. 	if po18_a>=6
gen 	LocalNewspapers		=	po18_b
replace LocalNewspapers		=. 	if po18_b>=6
gen 	TV					=	po18_c
replace TV					=. 	if po18_c>=6
gen 	Radio				=	po18_d
replace Radio				=. 	if po18_d>=6
gen 	DirectContact		=	po18_i
replace DirectContact		=. 	if po18_i>=6
gen 	DiscussionOthers	=	po18_j
replace DiscussionOthers	=. 	if po18_j>=6

gen Sector		=	spm55
replace Sector	=	spm62 if Sector==.
tab Sector

gen 	Sector4	=	1 if Sector==1 | Sector==2 | Sector==3  /* Private sector */
replace Sector4	=	2 if Sector==4 | Sector==5  /* Local government */
replace Sector4	=	3 if Sector==6				 /* Central government */
replace Sector4	=	4 if Sector>=7   /* Other */

keep year knr NationalNewspapers LocalNewspapers TV Radio DirectContact DiscussionOthers Sector 
save N2003.dta, replace

append using "C:\Users\FAG89001\Dropbox\SASDATA\Lokalvalgsundersøkelsene 01.03 2018\Data\N2007.dta"
append using "C:\Users\FAG89001\Dropbox\SASDATA\Lokalvalgsundersøkelsene 01.03 2018\Data\N2011.dta"
append using "C:\Users\FAG89001\Dropbox\SASDATA\Lokalvalgsundersøkelsene 01.03 2018\Data\N2015.dta"
save LocalInformation20032015.dta, replace

*** Generating Appendix Figure B1
label define Sector4_lab 1 "Private sector" 2 "Local government" 3 "Central government" 4 "Other"
label values Sector4 Sector4_lab

set scheme s1mono
graph bar LocalNewspapers DiscussionOthers TV NationalNewspapers Radio DirectContact SocialMedia, over(Sector4, label(labsize(small))) ytitle("Indicator of importance") ///
legend(lab (1 "Local newspapers")  lab (2 "Discussion with others")  lab (3 "Television") lab (4 "National newspapers")  lab(5 "Radio")  lab(6 "Direct contact with politicians") lab(7 "Social media") col(3) size(vsmall))
graph save FigureB1.gph, replace
graph export FigureB1.pdf, as(pdf) replace 
graph export FigureB1.tiff, as(tif) replace 

*****************
erase using N2003.dta
erase using N2007.dta
erase using N2011.dta
erase using N2015.dta

